package com.breaking.second.activity.pager;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.viewbinding.ViewBinding;

import com.breaking.second.application.EscortApplication;
import com.breaking.second.entity.PageableVo;
import com.breaking.second.entity.UserLoginEntity;
import com.breaking.second.utils.ViewBindingUtil;

public class BaseFragment<t extends ViewBinding> extends Fragment {
    public final PageableVo pageableVo = new PageableVo();
    public t binding;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        UserLoginEntity userLoginEntity = EscortApplication.getUserLoginEntity();
        if (userLoginEntity != null) {
            pageableVo.setUserId(userLoginEntity.getId());
        }
        binding = ViewBindingUtil.inflate(getClass(), inflater, container, false);
        if (binding != null) {
            return binding.getRoot();
        } else {
            throw new RuntimeException(getClass().getName() + ":布局转换失败");
        }
    }
}
